package com.management.department.teacherinfosystem.Repository;

import com.management.department.teacherinfosystem.Entity.TextbookAuthor;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface TextbookAuthorRepository extends JpaRepository<TextbookAuthor, Long> {
    List<TextbookAuthor> findByTextbook_Id(Long textbookId);

    @Modifying
    @Transactional
    @Query("DELETE FROM TextbookAuthor a WHERE a.textbook.id = :textbookId")
    void deleteByTextbookId(@Param("textbookId") Long textbookId);
} 